class Tool extends HtmlNode{
    constructor({type,details,tools}) {
        super(`.layui-colla-item[data-type=${type}]`);
        //创建标题区域
        this.titleEL=new HtmlNode('h2.layui-colla-title',this)
        this.titleEL.bindTextContent(this,'title')
        this.title=details
        let requiredCount=new HtmlNode('span.layui-badge',this.titleEL)
        requiredCount.textContent='0'
        requiredCount.el.style.display='none'
        requiredCount.bindTextContent(this,'requiredCount',{
            set(value){
                value = typeof value !== 'number'?parseInt(value):value
                if (value > 0){
                    requiredCount.el.style.display=''
                }else{
                    requiredCount.el.style.display='none'
                }
                requiredCount.textContent=value
            }
        })
        //创建内容区域
        this.content=new HtmlNode("table.files",new HtmlNode(".layui-colla-content",this))
        this.items=[]
        if (tools){
            tools.forEach(item=>this.appendItem(new Item(item)))
        }
    }

    appendItem(item){
        this.items.push(item)
        if (item.required){
            this.requiredCount=parseInt(this.requiredCount)+1

        }
        this.content.appendChild(item)
    }
}